﻿@model SevenSpikes.Nop.AjaxFilters.Models.NopAjaxFiltersModel
@{
    var storeLocation = Nop.Core.Infrastructure.EngineContext.Current.Resolve<Nop.Core.IWebHelper>().GetStoreLocation();
}
<script type="text/javascript">
    var nop_store_directory_root = "@(storeLocation)";
</script>
@{
    if (Model.NopAjaxFiltersSettingsModel.EnablePriceRangeFilter ||
        Model.NopAjaxFiltersSettingsModel.EnableAttributesFilter ||
        Model.NopAjaxFiltersSettingsModel.EnableSpecificationsFilter ||
        Model.NopAjaxFiltersSettingsModel.EnableManufacturersFilter)
    {
        Html.AddScriptParts(Url.Content("~/Plugins/SevenSpikes.Core/Scripts/kendo.all.min.js"));
        
        /*Kendo UI specific css files.

        kendo.common.min.css - it contains common kendo styles
        kendo.default.min.css - it contains deafult kendo theme specific styles. You can use the kendo theme builder for new themes - http://demos.kendoui.com/themebuilder/index.html

        */
        Html.AddCssFileParts(Url.Content("~/Plugins/SevenSpikes.Core/Styles/kendo.common.min.css"));
        Html.AddCssFileParts(Url.Content("~/Plugins/SevenSpikes.Core/Styles/kendo.default.min.css"));

        Html.AddScriptParts("//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js");
        Html.AddScriptParts(Url.Content("~/Plugins/SevenSpikes.Nop.AjaxFilters/Scripts/jquery.query-2.1.7.js"));
        Html.AddScriptParts(Url.Content("~/Plugins/SevenSpikes.Nop.AjaxFilters/Scripts/jquery.json-2.2.min.js"));
        Html.AddScriptParts(Url.Content("~/Plugins/SevenSpikes.Nop.AjaxFilters/JQueryTemplates/jDropDown.jquery.0.1.min.js"));
        Html.AddScriptParts("https://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js");
        Html.AddScriptParts(Url.Content("~/Plugins/SevenSpikes.Nop.AjaxFilters/Scripts/Filters.js"));

        var theme = Model.NopAjaxFiltersSettingsModel.Theme;

        Html.AddCssFileParts(Url.Content("~/Plugins/SevenSpikes.Nop.AjaxFilters/Themes/" + theme + "/Content/SevenSpikesNopUI.css"));
        if (Model.NopAjaxFiltersSettingsModel.EnablePriceRangeFilter)
        {
            Html.AddCssFileParts(Url.Content("~/Plugins/SevenSpikes.Nop.AjaxFilters/Themes/" + theme + "/Content/PriceRangeFilterSlider.css"));
        }
    }
    else
    {
        // no filters enabled, so simply return
        return;
    }


    MvcHtmlString priceRangeFilter = MvcHtmlString.Empty;
    MvcHtmlString specificationsFilter = MvcHtmlString.Empty;
    MvcHtmlString attributesFilter = MvcHtmlString.Empty;
    MvcHtmlString manufacturersFilter = MvcHtmlString.Empty;

    if (Model.NopAjaxFiltersSettingsModel.EnablePriceRangeFilter)
    {
        priceRangeFilter = Html.Action("GetPriceRangeFilter", "PriceRangeFilterSlider7Spikes");
    }

    if (Model.NopAjaxFiltersSettingsModel.EnableSpecificationsFilter)
    {
        specificationsFilter = Html.Action("GetSpecificationFilter", "SpecificationFilter7Spikes");
    }

    if (Model.NopAjaxFiltersSettingsModel.EnableAttributesFilter)
    {
        attributesFilter = Html.Action("GetProductAttributeFilter", "AttributeFilter7Spikes");
    }

    if (Model.NopAjaxFiltersSettingsModel.EnableManufacturersFilter)
    {
        manufacturersFilter = Html.Action("GetManufacturerFilter", "ManufacturerFilter7Spikes");
    }

    if (MvcHtmlString.IsNullOrEmpty(priceRangeFilter) && MvcHtmlString.IsNullOrEmpty(specificationsFilter)
        && MvcHtmlString.IsNullOrEmpty(attributesFilter) && MvcHtmlString.IsNullOrEmpty(manufacturersFilter))
    {
        return;
    }
}
<div class="nopAjaxFilters7Spikes" data-categoryId="@Model.CategoryId" data-getFilteredProductsUrl="@Url.Action("GetFilteredProducts", "Catalog7Spikes")"
    data-productsListPanelSelector="@Model.NopAjaxFiltersSettingsModel.ProductsListPanelSelector"
    data-productsGridPanelSelector="@Model.NopAjaxFiltersSettingsModel.ProductsGridPanelSelector"
    data-pagerPanelSelector="@Model.NopAjaxFiltersSettingsModel.PagerPanelSelector"
    data-sortOptionsDropDownSelector="@Model.NopAjaxFiltersSettingsModel.SortOptionsDropDownSelector"
    data-viewOptionsDropDownSelector="@Model.NopAjaxFiltersSettingsModel.ViewOptionsDropDownSelector"
    data-productsPageSizeDropDownSelector="@Model.NopAjaxFiltersSettingsModel.ProductPageSizeDropDownSelector"
    data-filtersUIMode="@Model.NopAjaxFiltersSettingsModel.FiltersUIMode.ToString().ToLower()"
    data-defaultViewMode="@Model.DefaultViewMode">
    <div class="filtersTitlePanel">
        <p class="filtersTitle">@T("SevenSpikes.NopAjaxFilters.Client.Common.FilterBy"):</p>
        <a class="clearFilterOptionsAll">@T("SevenSpikes.NopAjaxFilters.Client.Common.ClearAll")</a>
        <div class="clear">
        </div>
    </div>
    @priceRangeFilter
    @specificationsFilter
    @attributesFilter
    @manufacturersFilter
</div>
@Html.Hidden("availableSortOptionsJson", Model.AvailableSortOptionsJson)
@Html.Hidden("availableViewModesJson", Model.AvailableViewModesJson)
@Html.Hidden("availablePageSizesJson", Model.AvailablePageSizesJson)
